package com.ylbh.modules.commission.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ylbh.common.pojo.commission.dto.CommissionDTO;
import com.ylbh.common.pojo.commission.vo.CommissionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ylbh.common.utils.PageUtils;

import com.ylbh.modules.commission.mapper.ShoppingCommissionMapper;
import com.ylbh.modules.commission.entity.ShoppingCommission;
import com.ylbh.modules.commission.service.ShoppingCommissionService;

import java.util.List;


@Service("shoppingCommissionService")
public class ShoppingCommissionServiceImpl extends ServiceImpl<ShoppingCommissionMapper, ShoppingCommission> implements ShoppingCommissionService {

    @Autowired
    private ShoppingCommissionMapper shoppingCommissionMapper;

    /**
     * 返佣提现列表
     * @param dto
     * @return
     */
    @Override
    public PageUtils queryCommissionList(CommissionDTO dto) {
        Page<Integer> page = new Page<>(dto.getPage(), dto.getLimit());
        List<CommissionVO> list = shoppingCommissionMapper.selectCommissionList(dto, page);
        return new PageUtils(new Page<CommissionVO>().setTotal(page.getTotal()).setRecords(list));
    }

    /**
     * 审核返佣提现
     * @param commissionId
     */
    @Override
    public void reviewOfWithdrawalOfCommissionById(String commissionId) {
        shoppingCommissionMapper.updateReviewOfWithdrawalOfCommissionById(commissionId);
    }

    /**
     * 获取返佣详情信息
     * @param commissionId
     * @return
     */
    @Override
    public CommissionVO getCommissionDetailsInfoById(String commissionId) {
        return shoppingCommissionMapper.selectCommissionDetailsInfoById(commissionId);
    }
}
